package com.ruoyi;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.Scanner;

/**
 * 启动程序
 * 
 * @author ruoyi
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication
{
    public static void main(String[] args)
    {



        Properties properties = new Properties();
        String path = "/home/ruoyi/uploadPath/config.properties";
//        String path = "D:\\java\\portal\\ruoyi-admin\\src\\main\\resources\\config.properties";
        try (FileInputStream fis = new FileInputStream(path)) {
            properties.load(fis);
        } catch (IOException e) {
            try (FileInputStream fis = new FileInputStream("D:\\java\\portal\\ruoyi-admin\\src\\main\\resources\\config.properties");) {
                properties.load(fis);
            } catch (IOException e2) {
                e.printStackTrace();
                System.exit(1);
            }
//            e.printStackTrace();
//            System.exit(1);
        }

//        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入密码：");
//        String password = scanner.nextLine();

        if (validatePassword("adwgsdhqaqwez123", properties.getProperty("password"))) {
            System.out.println("密码正确，程序启动！");
            SpringApplication.run(RuoYiApplication.class, args);
            // 在这里放置你的程序逻辑
            System.out.println("(♥◠‿◠)ﾉﾞ  去吧！皮卡丘，看你的了   ლ(´ڡ`ლ)ﾞ  \n" +
                    "\"(\\\\__/)\\n\" +\n" +
                    "\"(='.'=)\\n\" +\n" +
                    "\"(\\\")_(\\\")\\n\";");
            // 在这里放置你的程序逻辑
        } else {
            System.out.println("密码错误，程序终止！");
            System.exit(1);
        }

    }

    private static boolean validatePassword(String password, String correctPassword) {
        return correctPassword.equals(password);
    }
}
